package com.kavin.design.factory.simpleFactory;

import com.kavin.design.factory.Audi;
import com.kavin.design.factory.Byd;
import com.kavin.design.factory.Car;

public class CarFactory {
    /**
     * 创建汽车
     * @param type
     * @return
     */
    public static Car createCar(String type){
        //该方法还会有问题，假如以后有很多汽车都需要工厂来创建。则又得修改源代码，违反了OCP开闭原则
        if ("audi".equals(type)) {
            return new Audi();
        }else if ("byd".equals(type)) {
            return new Byd();
        }else{
            return null;
        }
    }
}